package bishizhuanyong.迅雷.Main2;
import java.util.Scanner;


public class Main {
    static int maxlen=10000;
    static  int count=0;
    static int rl=0;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] arr=new int[maxlen];
        long[] pre_sum=new long[maxlen];
        int len=0;
        long presum=0;
        while (in.hasNextInt()) {
            int a = in.nextInt();
            presum+=a;
            arr[len]=a;
            pre_sum[len]+=presum;
            len++;
        }
        if (len<=2){
            System.out.println(0);
            return;
        }
        rl=len;
        int i=0;
        int j=1;
        boolean[][] visited=new boolean[len][len];
        process(pre_sum,0,1,visited);
        System.out.println(count);
    }

    public static void process(long[] pre_sum,int i,int j,boolean[][] visited){
        if (i>=j)
            return;
        if (j>=rl-1)
            return;
        if (i<0)
            return;
        if (visited[i][j])
            return;
        visited[i][j]=true;
        long mid=pre_sum[j]-pre_sum[i];
        long pre=pre_sum[i];
        long end=pre_sum[rl-1]-pre_sum[j];
        if (mid>=pre&&end>=mid){
            count++;
            process(pre_sum,i,j++,visited);
            process(pre_sum,i++,j,visited);
            process(pre_sum,i++,j++,visited);
            process(pre_sum,i--,j,visited);
            process(pre_sum,i,j--,visited);
            process(pre_sum,i--,j--,visited);
        }else if (mid>=pre&&end<mid){
            process(pre_sum,i,j++,visited);
            process(pre_sum,i++,j,visited);
            process(pre_sum,i++,j++,visited);
            process(pre_sum,i--,j,visited);
            process(pre_sum,i,j--,visited);
            process(pre_sum,i--,j--,visited);
        }else if (mid<pre&&end>=mid){
            process(pre_sum,i,j++,visited);
            process(pre_sum,i++,j,visited);
            process(pre_sum,i++,j++,visited);
            process(pre_sum,i--,j,visited);
            process(pre_sum,i,j--,visited);
            process(pre_sum,i--,j--,visited);
        }else {
            process(pre_sum,i,j++,visited);
            process(pre_sum,i++,j,visited);
            process(pre_sum,i++,j++,visited);
            process(pre_sum,i--,j,visited);
            process(pre_sum,i,j--,visited);
            process(pre_sum,i--,j--,visited);
        }
    }

}
